
import startDialogVue from '@/views/Maintain/start-dialog.vue';
<template>
  <div id="box">
    <div style="margin-top: 10px">
      <el-button :type="primarynum == 0 ? 'primary' : ''" @click="btn_type(0)"
        >会议类型配置</el-button
      >
      <el-button :type="primarynum == 1 ? 'primary' : ''" @click="btn_type(1)"
        >合同维护配置</el-button
      >
      <el-button :type="primarynum == 2 ? 'primary' : ''" @click="btn_type(2)"
        >合同续签配置</el-button
      >
      <el-button :type="primarynum == 3 ? 'primary' : ''" @click="btn_type(3)"
        >历史合同配置</el-button
      >
      <el-button :type="primarynum == 3 ? 'primary' : ''" @click="btn_type(4)"
        >采购类别</el-button
      >
    </div>
    <el-form v-if="primarynum == 1 || primarynum == 2 || primarynum == 3 " class="form my-search-form-box" inline>
      <div class="my-search-form-left saixuan">
        <el-form-item label="采购类别：">
          <el-cascader
            v-model="params"
            :options="years"
            :props="{ expandTrigger: 'hover' }"
            @change="handleChange"
          ></el-cascader>
        </el-form-item>
      </div>
    </el-form>

    <div v-if="primarynum == 0" class="aaa">
      <auth2> </auth2>
    </div>

    <div v-if="primarynum == 1 || primarynum == 2 || primarynum == 3">
      <div v-for="(item, key) in title_children_lists" :key="item.fjmc">
        <div class="h3">
          <h1 style="display: flex; justify-content: space-between">
            <div>{{ item.name }}</div>
            <div class="btn_add_c">
              <el-button type="primary" @click="btn_wxz(item, key)"
                >新 增</el-button
              >
            </div>
          </h1>
          <div class="checkbox">
            <div style="margin: 15px 0"></div>

            <my-table-pagination
              :data="item.children"
              :tableHeight="450"
              :isPagination="false"
              :tableColumns="payTableColumns"
              class="table-box"
            >
              <el-table-column align="center" slot="ispay" label="支付状态">
                <template slot-scope="{ row }">
                  <div>
                    <div v-if="row.state == '0'" style="color: #e36d1e">
                      停用
                    </div>
                    <div v-if="row.state == '1'" style="color: #1eb71e">
                      启用
                    </div>
                  </div>
                </template>
              </el-table-column>

              <el-table-column
                slot="img"
                align="center"
                width="200"
                label="操作"
              >
                <template slot-scope="scope">
                  <div style="color: #409eff" class="imgname">
                    <span
                      class="anniu"
                      style="margin-right: 10px"
                      @click="btn_c(scope.$index, scope.row, 0)"
                    >
                      {{ scope.row.state == 0 ? "启用" : "停用" }}
                    </span>
                    <span
                      class="anniu"
                      @click="btn_c(scope.$index, scope.row, 1)"
                    >
                      修改
                    </span>
                    <span
                      class="anniu"
                      v-if="scope.row.resource == '2'"
                      style="margin-left: 10px"
                      @click="btn_c(scope.$index, scope.row, 2)"
                    >
                      删除
                    </span>
                  </div>
                </template>
              </el-table-column>
            </my-table-pagination>
          </div>
        </div>
      </div>
      <el-dialog
        title="新增自定义配置"
        :visible.sync="dialogVisible"
        width="30%"
        append-to-body
        :before-close="handleClose"
      >
        <el-input v-model="input_add" placeholder="请输入自定义配置"></el-input>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="btn_add">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog
        title="修改配置文件"
        append-to-body
        :visible.sync="dialogVisible_1"
        width="30%"
      >
        <el-input
          v-model="input_add_xg"
          placeholder="请输入自定义配置"
        ></el-input>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible_1 = false">取 消</el-button>
          <el-button type="primary" @click="btn_xiugai_queding"
            >确 定</el-button
          >
        </span>
      </el-dialog>
    </div>
    <div v-if="primarynum == 4">
      <primarynum4 />
    </div>
  </div>
</template> 

<script>
import auth2 from '../newauth/newindex3.vue'
import primarynum4 from '../ContractAllocationLook/index.vue';
const payTableColumns = [
  {
    label: '序号',
    type: 'index',
    width: 100,
  },

  {
    label: '文件名称',
    align: 'right',
    prop: 'fjmc',
  },

  {
    slot: 'ispay',
    width: 100,
  },
  {
    slot: 'img',
    width: 100,
  },
]
export default {
  name: '',
  components: { auth2 ,primarynum4},
  data() {
    return {
      boxshow: false,
      payTableColumns,
      primarynum: 0,
      btn_radio_id: '105',
      input_add_xg: '',
      number_city: 0,
      xingzengitem: {},
      dialogVisible_1: false,
      
      params: '',
      relationarr: [],
      truelabel: 0,
      dialogVisible: false,
      leibie_list: [
        {
          name: '公开招标',
          value: '1',
        },
        {
          name: '邀请招标',
          value: '2',
        },
        {
          name: '竞争性谈判',
          value: '3',
        },
        {
          name: '竞争性磋商',
          value: '4',
        },
        {
          name: '单一来源',
          value: '5',
        },
        {
          name: '电子化平台',
          value: '6',
        },
        {
          name: '政采中心',
          value: '7',
        },
        {
          name: '非政采',
          value: '8',
        },
      ],
      years: [],
      name_number: 0,
      checkAll: false,
      checkedCities_add: [],
      input_add: '',
      
      isIndeterminate: true,
      title_children_lists: [],
      leibie_lis_zcid: '',
      ids: '',
      ids_xg: '',
    }
  },
  created() {
    this.select_list()
  },
  props: {},
  methods: {
    btn_c(index, row, number) {
      console.log(row, index, number)
      if (number == 0) {
        
        this.btn_TY(row.state, row.id)
      }
      if (number == 1) {
        this.btn_xiugai(row.id, row.relationId, index)
      }
      if (number == 2) {
        this.btn_shanchu(row.id, row.relationId, index)
      }
    },
    btn_TY(e, k) {
      if (e == 1) {
        var state = 0
      } else {
        var state = 1
      }
      this.$axios
        .post('/info/ContractBFj/updateStateFj', {
          id: k,
          state: state,
        })
        .then((res) => {
          this.suoyoufujian()
        })
    },
    btn_type(e) {
      this.primarynum = e
      console.log(this.primarynum)
      this.leibie_lis_zcid = ''
      this.ids = ''
      if (e == 0) {
        return
      }
      this.select_list()
    },
    btn_radio(e) {
      this.leibie_lis_zcid = e
      this.suoyoufujian()
    },

    select_list() {
      this.boxshow = false
      this.$axios.get('/other/external/getPolicyList').then((res) => {
        console.log('获取筛选数据', res.data.data[0].children[0].value)
        if (res.data.data) {
          this.years = res.data.data
          this.params = [
            res.data.data[0].value,
            res.data.data[0].children[0].value,
          ]
          this.leibie_lis_zcid = res.data.data[0].children[0].value
          this.title_children_list()
        }
      })
    },
    handleChange(e) {
      console.log('选中的哪一个类别', e)
      console.log('选中的哪一个类别', e[e.length - 0 - 1])
      this.leibie_lis_zcid = e[e.length - 0 - 1]
      this.ids = this.leibie_lis_zcid
      if (this.leibie_lis_zcid == 105) {
        this.suoyoufujian()
      } else {
        this.suoyoufujian()
      }
    },
    title_children_list() {
      this.$axios.get('/info/ContractBFj/getCategory').then((res) => {
        console.log('title_children_list', res)
        if (res.data.data) {
          this.title_children_lists = res.data.data
          this.suoyoufujian()
        }
      })
    },
    suoyoufujian() {
      
      this.$axios
        .post('/info/ContractBFj/getList', {
          type: this.primarynum,
          cglxId: this.leibie_lis_zcid,
        })
        .then((res) => {
          console.log(res)
          if (res.data.data) {
            if (this.primarynum == 3) {
              console.log(this.title_children_lists)
              this.title_children_lists = [
                { name: '', fjflid: '', children: res.data.data },
              ]
              let aa = []
              res.data.data.forEach((rs) => {
                if (rs.relation == '1') {
                  aa.push(rs.id)
                }
                this.$set(this.relationarr, 0, aa)
              })
            } else {
              console.log(this.title_children_lists)
              for (let i in this.title_children_lists) {
                let children = []
                let relation = []
                this.title_children_lists[i].children = []
                res.data.data.forEach((hmp) => {
                  if (this.title_children_lists[i].fjflid == hmp.fjflid - 0) {
                    children.push(hmp)
                    if (hmp.relation == '1') {
                      relation.push(hmp.id)
                    }
                    this.$set(this.relationarr, i, relation)
                    this.title_children_lists[i].relation = relation
                    this.title_children_lists[i].children = children
                  } else {
                  }
                })
              }
              console.log(this.title_children_lists)
              this.$forceUpdate()
              this.boxshow = true
            }
          }
        })
    },
    title_list() {
      this.$axios.get('/info/ContractBFj/getCglx').then((res) => {
        console.log(res)
        if (res.data.data) {
          this.leibie_list = res.data.data
          this.suoyoufujian()
        }
      })
    },
    btn_xiugai(e, k, s) {
      console.log(e, k, s)
      this.truelabel = 1
      this.ids_xg = e
      this.number_city = s
      this.dialogVisible_1 = true
      setTimeout(() => {
        this.truelabel = 0
      }, 50)
    },
    btn_xiugai_queding() {
      this.$axios
        .post('/info/ContractBFj/modifyFj', {
          fjmc: this.input_add_xg,
          id: this.ids_xg,
        })
        .then((res) => {
          console.log(res)
          if (res.data) {
            this.$message({
              message: '已成功修改',
              type: 'success',
            })
            this.input_add_xg = ''
            this.suoyoufujian()

            this.dialogVisible_1 = false
          }
        })
    },
    btn_tingyong(e, k, l) {
      if (e.relation == '0') {
        this.$axios
          .post('/info/ContractBFj/addContractBF', {
            cglxId: this.leibie_lis_zcid,
            fjlxId: k,
            type: this.primarynum + '',
          })
          .then((res) => {
            this.suoyoufujian()
          })
      } else {
        this.$axios
          .post('/info/ContractBFj/addContractBF', {
            cglxId: this.leibie_lis_zcid,
            fjlxId: k,
            id: l,
            type: this.primarynum + '',
          })
          .then((res) => {
            this.suoyoufujian()
          })
      }
    },
    btn_shanchu(e, k) {
      this.truelabel = 1
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.$axios
            .post('/info/ContractBFj/addContractBCodeFjTypeEntity', {
              id: e,
            })
            .then((res) => {
              console.log(res)
              if (res.data) {
                this.$message({
                  message: '删除成功',
                  type: 'success',
                })
                this.suoyoufujian()
                
                setTimeout(() => {
                  this.truelabel = 0
                }, 50)
              }
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除',
          })
        })
    },
    btn_wxz(e, k) {
      console.log(e, k, this.title_children_lists)
      this.xingzengitem = {
        data: e,
        index: k,
      }
      this.dialogVisible = true
    },
    handleClose(done) {
      this.dialogVisible = false
    },
    btn_add() {
      this.dialogVisible = false
      var num = 0
      if (this.title_children_lists[this.xingzengitem.index].children) {
        this.title_children_lists[this.xingzengitem.index].children.forEach(
          (io) => {
            if (io.fjmc == this.input_add) {
              this.$message.error({
                message: '新增失败，已有相同的自定义附件',
              })
              this.input_add = ''
              num = 1
              return
            }
          }
        )
      }

      if (num == 0) {
        this.$axios
          .post('/info/ContractBFj/addContractBCodeFjTypeEntity', {
            fjmc: this.input_add,
            type: this.primarynum,
            fjflid: this.xingzengitem.data.fjflid,
          })
          .then((res) => {
            this.select_list()
          })
        this.input_add = ''
      }
    },
    
    handleCheckAllChange(val) {
      this.checkedCities_1 = val
        ? this.cities_1.map((num_value) => num_value.value)
        : []
      this.isIndeterminate = false
    },
    
    handleCheckedCitiesChange_add(e) { },

    
    handleCheckedCitiesChange(value, k, l) {
      console.log(
        '是否选中：',
        value,
        'id:',
        k,
        'relationId',
        l,
        this.truelabel
      )

      if (this.truelabel == 0) {
        if (value) {
          if (this.primarynum == 3) {
            this.$axios
              .post('/info/ContractBFj/addContractBF', {
                fjlxId: k,
                type: this.primarynum + '',
              })
              .then((res) => {
                this.suoyoufujian()
              })
          } else {
            this.$axios
              .post('/info/ContractBFj/addContractBF', {
                cglxId: this.leibie_lis_zcid,
                fjlxId: k,
                type: this.primarynum + '',
              })
              .then((res) => {
                this.suoyoufujian()
              })
          }
        } else {
          if (this.primarynum == 3) {
            this.$axios
              .post('/info/ContractBFj/addContractBF', {
                id: l,
                fjlxId: k,
                type: this.primarynum + '',
              })
              .then((res) => {
                this.suoyoufujian()
              })
          } else {
            this.$axios
              .post('/info/ContractBFj/addContractBF', {
                cglxId: this.leibie_lis_zcid,
                fjlxId: k,
                id: l,
                type: this.primarynum + '',
              })
              .then((res) => {
                this.suoyoufujian()
              })
          }
        }
      }

      
      
      
      
    },
    
    btn_name(e, k) {
      this.name_number = k
      this.suoyoufujian()
    },
  },
}
</script>

<style lang='scss' scoped>
/deep/ .has-gutter {
  .cell {
    text-align: center;
  }
}

.anniu {
  cursor: pointer;
}
/deep/ .el-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  .asdzxcaweq {
    display: flex;
    align-items: center;
    min-width: 200px;
    margin-bottom: 50px;
    width: calc(90% / 4);

    
  }
 ::v-deep .el-checkbox {
    max-width: calc(100% - 20px);
  }
}

.my-search-form-box {
  margin-top: 20px;
  .el_radio {
    margin-left: 20px;
    height: 42px;
    line-height: 42px;
  }
  justify-content: flex-start;
}
/deep/ .el-form {
  height: 42px;
  padding: 5px 10px;
  
  .saixuan {
    height: 40px;
    .el-form-item {
      margin-bottom: 0;
    }
  }
}
#box {
  
  height: auto !important;
  min-height: calc(100% - 10px);
  
  width: 100%;
}
.aaa {
  width: 100%;
  height: 86vh;
}
/deep/ .is-vertical {
  display: none;
}

/deep/ .el-checkbox__input {
  .el-checkbox__inner {
    margin-top: 6px;
  }
}
/deep/ .el-form-item__label {
  font-size: 14px;
  margin-top: 5px;
}
.block {
  width: 100%;
  display: flex;
  margin-top: -16px;

  .name:first-child {
    border-left: 1px solid #ccc;
  }
  .name {
    overflow: hidden;
  }
  .actaik {
    color: #369fff;
  }
  div {
    height: 57px;
    text-align: center;
    line-height: 57px;
    user-select: none;
    font-family: Microsoft YaHei, Microsoft YaHei-Regular;
    font-weight: bold;
    color: #666666;
    cursor: pointer;
    font-size: 19px;
    width: calc(100% / 8 + 4px);
    border: 1px solid #ccc;
    border-top: none;
    border-left: none;
  }
}
.btn_add_c {
  text-align: right;
}
.ovflws {
  width: 100%;
}
.h3 {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  margin-top: 34px;
  padding: 20px;
  border-radius: 5px;
  .checkbox {
    margin-top: 50px;
  }
 ::v-deep .el-checkbox-group {
    padding: 0 5%;
    .el-checkbox {
      
      .el-checkbox__label {
        font-size: 16px;
        font-family: Microsoft YaHei, Microsoft YaHei-Regular;
        font-weight: 400;
        color: #666666;
      }
      .asdzxc {
        display: flex;
        width: 100%;
        height: 20px;
        .fjmc {
          max-width: 90%;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .icons {
          text-align: center;
          min-width: 10%;
        }
      }

      
    }
  }

  h1 {
    margin-top: 20px;
    height: 19px;
    padding-left: 1%;
    opacity: 1;
    font-size: 20px;
    font-family: Microsoft YaHei, Microsoft YaHei-Regular;
    font-weight: bold;
    text-align: left;
    color: #666666;
    line-height: 32px;
  }
}
/deep/ .el-dialog {
  margin-top: 20% !important;
  .el-dialog__header {
    text-align: center;
  }
}
/deep/ .el-checkbox__input {
  margin-top: -7px;
}

.add {
  
  

  margin-top: 20px;
  border-radius: 5px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  .add_checkbox {
    padding: 0px 5%;
   ::v-deep.el-checkbox {
      margin-bottom: 0px;
      height: 24px;

      .el-checkbox__label {
        
        position: relative;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
 ::v-deep .el-checkbox__label {
    font-size: 16px;
  }
  .xiantiao {
    display: flex;
    justify-content: space-between;
    padding: 20px 5%;
    .zidingyi {
      font-size: 20px;
      font-family: Microsoft YaHei, Microsoft YaHei-Regular;
      font-weight: bold;
      color: #666666;
    }
  }
}
/deep/ .cell {
  height: 40px;
  line-height: 40px;
}
</style>



